//
//  Shebei_guanli_CvCell.m
//  ainkjj
//
//  Created by zhiyiLiu on 2020/3/5.
//  Copyright © 2020 zhiyiLiu. All rights reserved.
//

#import "Shebei_guanli_CvCell.h"
#import "Tuichu_quren_popView.h"
@interface Shebei_guanli_CvCell()
@property (weak, nonatomic) IBOutlet UIImageView *icon_iv;

@property (weak, nonatomic) IBOutlet UILabel *name_lb;

@end

@implementation Shebei_guanli_CvCell
- (IBAction)del_action:(UIButton *)sender {
    sender.userInteractionEnabled = NO;
    
    
//    MMPopupCompletionBlock btnBlock = ^(MMPopupView *popupView, BOOL finished){
//
//        DLog(@"%d", finished);
//        if (finished) {
//
//            if (self.del_blk) {
//                self.del_blk(self.idx);
//            }
//        }
//    };
//
//    Tuichu_quren_popView *pinView = [Tuichu_quren_popView new];
//    pinView.img_name = @"ad_remind_icon";
//    pinView.tipStr = [NSString stringWithFormat:@"是否解除%@的绑定", self.entity.device_name];
//    pinView.btnBlock = btnBlock;
//    [pinView show];
//
    
    
    QMUIDialogViewController *dialogViewController = [[QMUIDialogViewController alloc] init];
    dialogViewController.title = @"解除绑定";
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];
    contentView.backgroundColor = UIColorWhite;
    UILabel *label = [[UILabel alloc] qmui_initWithFont:UIFontMake(14) textColor:UIColorBlack];
    label.text = [NSString stringWithFormat:@"是否解除 %@ 的绑定", self.entity.device_name];
    label.frame = CGRectMake(10, 0, CGRectGetWidth(contentView.frame) - 20, QMUIViewSelfSizingHeight);
    label.numberOfLines = 0;
    label.center = CGPointMake(CGRectGetWidth(contentView.bounds) / 2.0, CGRectGetHeight(contentView.bounds) / 2.0);
    [label sizeToFit];
    [contentView addSubview:label];
    dialogViewController.contentView = contentView;
    [dialogViewController addSubmitButtonWithText:@"确定" block:^(QMUIDialogViewController *aDialogViewController) {
        [aDialogViewController hide];
        if (self.del_blk) {
            self.del_blk(self.idx);
        }
    }];
    [dialogViewController addCancelButtonWithText:@"取消" block:nil];

    [dialogViewController show];
    sender.userInteractionEnabled = YES;

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    self = [[NSBundle mainBundle] loadNibNamed:@"Shebei_guanli_CvCell" owner:self options:nil].lastObject;
//    self.contentView.backgroundColor = UIColor.redColor;
    return self;
}
- (void)setEntity:(App_devicesData *)entity{
    _entity = entity;
    [self.icon_iv sd_setImageWithURL:[NSURL URLWithString:entity.icon] placeholderImage:[UIImage imageNamed:@"ad_remove_icon"]];
    self.name_lb.text = entity.device_name;
}

@end
